package com.yjz.jvm.javaclone;

public class Car implements Cloneable {
  private String carName;

  private String carNo;

  private Wheel wheel;


  public Car(String carName, String carNo, Wheel wheel) {
    this.carName = carName;
    this.carNo = carNo;
    this.wheel = wheel;
  }

  public String getCarName() {
    return carName;
  }

  public void setCarName(String carName) {
    this.carName = carName;
  }

  public String getCarNo() {
    return carNo;
  }

  public void setCarNo(String carNo) {
    this.carNo = carNo;
  }

  public Wheel getWheel() {
    return wheel;
  }

  public void setWheel(Wheel wheel) {
    this.wheel = wheel;
  }

  @Override
  protected Object clone() throws CloneNotSupportedException {
    Car car = (Car) super.clone();
    car.setWheel((Wheel) car.getWheel().clone());
    return car;
  }
}
